import 'package:cat_eye/base/base_refresh_state.dart';
import 'package:cat_eye/bean/home_body_bean.dart';
import 'package:cat_eye/root_page/find_page/find_special_details_list_widet.dart';
import 'package:cat_eye/root_page/home_page/hom_video_page_widget.dart';
import 'package:cat_eye/root_page/home_page/video_details_widget.dart';
import 'package:cat_eye/util/util.dart';
import 'package:cat_eye/view_model/find_view_model/find_special_details_view_model.dart';
import 'package:flutter/material.dart';

/*
* @Package: root_page.find_page
* @ClassName: find_special_detalis_widget
* @Author: szj
* @CreateDate: 8/4/21 2:23 PM
* TODO 发现-专题-详情页面
*/
class FindSpecialDetailsWidget extends StatefulWidget {
  final int id;

  const FindSpecialDetailsWidget({
    Key key,
    @required this.id,
  }) : super(key: key);

  @override
  _FindSpecialDetailsWidgetState createState() =>
      _FindSpecialDetailsWidgetState();
}

class _FindSpecialDetailsWidgetState extends BaseRefreshState<
    FindSpecialDetailsWidget, FindSpecialDetailsViewModel> {
  @override
  FindSpecialDetailsViewModel get buildViewModel =>
      FindSpecialDetailsViewModel(widget.id);

  @override
  Widget buildWidget(BuildContext context, FindSpecialDetailsViewModel model) {
    return Scaffold(
      appBar: appBar("${model.issue.brief}"),
      body: CustomScrollView(
        slivers: [
          _headLayout(model),
          buildSliverList(model, context),
        ],
      ),
    );
  }

  Widget buildSliverList(FindSpecialDetailsViewModel model, context) {
    return SliverList(
      delegate: SliverChildBuilderDelegate((context, index) {
        return FindSpecialDetailsListWidget(item: model.itemList[index]);
      }, childCount: model.itemList.length),
    );
  }

  Widget _headLayout(FindSpecialDetailsViewModel model) {
    return SliverToBoxAdapter(
        child: Column(
      children: [
        Container(
          height: 240,
          child: Stack(
            children: [
              cacheImage(model.issue.headerImage,
                  width: MediaQuery.of(context).size.width, height: 220),
              Positioned(
                  left: 30,
                  right: 30,
                  bottom: 0,
                  //PhysicalModel 设置阴影
                  child: PhysicalModel(
                    color: Colors.white,
                    elevation: 10,
                    clipBehavior: Clip.antiAlias,
                    child: Container(
                      height: 40,
                      alignment: Alignment.center,
                      child: Text(
                       "${ model.issue.brief}",
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                            color: Colors.black, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ))
            ],
          ),
        ),
        Padding(
            padding: EdgeInsets.all(5),
            child: Text(
              "${model.issue.text}",
              style: TextStyle(color: Colors.grey),
            )),
        Divider(
          height: 20.0,

          //左侧向右侧移动60
          // indent: 60.0,
          color: Colors.black26,
        ),
      ],
    ));
  }
}
